import 'package:flutter/material.dart';
import 'package:flutter2/colors.dart';
import 'package:flutter2/utils/string.dart';
import 'package:flutter2/widget/base/base_container.dart';

class InfoBar extends StatefulWidget {
  const InfoBar({
    super.key,
    this.title,
    this.value,
    this.code,
    this.click,
  });

  final String? title;
  final String? value;
  final String? code;
  final Function()? click;

  @override
  State<InfoBar> createState() => _InfoBarState();
}

class _InfoBarState extends State<InfoBar> {
  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: widget.click,
      child: Container(
        width: double.infinity,
        margin: EdgeInsets.symmetric(horizontal: 16, vertical: 8),
        padding: EdgeInsets.only(left: 16, right: 16, top: 15, bottom: 15),
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.circular(10),
        ),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Row(
              crossAxisAlignment: CrossAxisAlignment.center,
              children: [
                Expanded(
                  child: Text(
                    widget.title ?? "",
                    style: TextStyle(color: mainText, fontSize: 14),
                  ),
                ),
                SizedBox(
                  width: 10,
                ),
                BaseContainer(
                  backgroundImg: "ic_right".toImage(),
                  width: 16,
                  height: 16,
                ),
              ],
            ),
            Offstage(
              offstage: widget.value?.isNotEmpty != true,
              child: SizedBox(
                height: 10,
              ),
            ),
            Offstage(
              offstage: widget.value?.isNotEmpty != true,
              child: Text(
                widget.value ?? "",
                style: TextStyle(fontSize: 14, color: mainText),
              ),
            )
          ],
        ),
      ),
    );
  }
}
